package com.dq.domain.evaluation;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @author liuhui
 * @date 2019/11/23 0023 10:44:05
 */
@Data
@Entity
@ApiModel("评价记录和模板子项关系表")
public class EvaluationRecordTemplate extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("评价记录")
    @ManyToOne
    protected EvaluationRecord evaluationRecord;

    @ApiModelProperty("评价模板子项")
    @ManyToOne
    protected EvaluationTemplateChild evaluationTemplateChild;

    @ApiModelProperty("评价模板")
    @ManyToOne
    protected EvaluationTemplate evaluationTemplate;

    @Data
    @ApiModel(value = "评价模板关系实体视图")
    public static class Vo implements VO {
        @ApiModelProperty("评价项目名称")
        protected String name;
        @ApiModelProperty("分数名称")
        protected String scoreName;
        @ApiModelProperty("分数")
        protected Long score;
        @ApiModelProperty("评价子项名称")
        protected String chirldName;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.name = fmt(this.getEvaluationTemplate().getName());
        vo.chirldName = this.getEvaluationTemplateChild().getTitle();
        vo.scoreName =fmt(this.getEvaluationTemplateChild().getTitle());
        vo.score = fmt(this.getEvaluationTemplateChild().getScore());
        return vo;
    }

}
